﻿using System.Diagnostics;
using System.Text;

Debug.Assert(Encode("") == "");
Debug.Assert(Encode("f") == "Zg==");
Debug.Assert(Encode("fo") == "Zm8=");
Debug.Assert(Encode("foo") == "Zm9v");
Debug.Assert(Encode("foob") == "Zm9vYg==");
Debug.Assert(Encode("fooba") == "Zm9vYmE=");
Debug.Assert(Encode("foobar") == "Zm9vYmFy");

Debug.Assert(Decode("") == "");
Debug.Assert(Decode("Zg==") == "f");
Debug.Assert(Decode("Zm8=") == "fo");
Debug.Assert(Decode("Zm9v") == "foo");
Debug.Assert(Decode("Zm9vYg==") == "foob");
Debug.Assert(Decode("Zm9vYmE=") == "fooba");
Debug.Assert(Decode("Zm9vYmFy") == "foobar");

string Encode(string text)
{
    return Base64Sample.Base64.Encode(Encoding.UTF8.GetBytes(text));
}

string Decode(string text)
{
    return Encoding.UTF8.GetString(Base64Sample.Base64.Decode(text));
}
